使用 Python 通过流将数据从 S3 传输到 FTP 服务器

您所在的位置:网站首页 aws s3 传输加速 使用 Python 通过流将数据从 S3 传输到 FTP 服务器

使用 Python 通过流将数据从 S3 传输到 FTP 服务器

2023-06-21 13:39| 来源: 网络整理| 查看: 265

使用 Python,我想将匹配模式的文件sample1从 AWS S3 直接复制到 FTP 服务器,而无需下载到本地临时位置。我尝试了以下操作:

import s3fs

from ftplib import FTP_TLS

s3 = s3fs.S3FileSystem(anon=False)

pattern = 'sample1'

rest = [i for i in list if pattern in i]

rest

ftp = FTP_TLS("ftp.test.com")

ftp.login(user ='myUser', passwd = 'PassWrd')

ftp.cwd("box_dest")

for f in rest:

    print(f)

    with open(f, 'r') as fu:

        ftp.storbinary('STOR ' + f, fu)

我越来越:

[u'test-bucket/abc/test/sample1.csv']

test-bucket/abc/test/sample1.csv

Traceback (most recent call last):

  File "", line 3, in

IOError: [Errno 2] No such file or directory: u'test-bucket/abc/test/sample1.csv'

关于如何实现这一目标的任何建议?谢谢!



【本文地址】


今日新闻


推荐新闻


    CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3